package org.example.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.commonapi.domain.AssignmentQuestions;
import org.example.commonapi.domain.ExamQuestions;
import org.example.commonapi.domain.R;
import org.example.commonapi.domain.StudentAssignmentAnswer;
import org.example.course.service.AssignmentQuestionsService;
import org.example.commonapi.mapper.AssignmentQuestionsMapper;
import org.example.course.service.StudentAssignmentAnswerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author DELL
* @description 针对表【assignment_questions】的数据库操作Service实现
* @createDate 2024-06-26 06:25:18
*/
@Service
public class AssignmentQuestionsServiceImpl extends ServiceImpl<AssignmentQuestionsMapper, AssignmentQuestions>
    implements AssignmentQuestionsService{

    @Resource
    private AssignmentQuestionsMapper assignmentQuestionsMapper;

    @Resource
    private StudentAssignmentAnswerService studentAssignmentAnswerService;

    @Override
    public R<String> submitAnswer(String answer, Integer id) {
        LambdaQueryWrapper<AssignmentQuestions> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AssignmentQuestions::getId, id);
        AssignmentQuestions assignmentQuestions = assignmentQuestionsMapper.selectOne(wrapper);
        if (assignmentQuestions.getAnswer().equals(answer)) {
            return R.success("正确");
        }else {
            return R.success("错误");
        }
    }


}




